/**
 * 给定N，已知 4x + 6y == N
 * 求 x + y 的最小和最大值
 */
#include <bits/stdc++.h>
using namespace std;
 
char *__abc147, *__xyz258, __ma369[100000];
#define __hv007() ((__abc147==__xyz258) && (__xyz258=(__abc147=__ma369)+fread(__ma369,1,100000,stdin),__abc147==__xyz258) ? EOF : *__abc147++)

using llt = long long;

llt getInt(){
	int sgn = 1;
	char ch = __hv007();
	while( ch != '-' && ( ch < '0' || ch > '9' ) ) ch = __hv007();
	if ( '-' == ch ) {sgn = 0;ch=__hv007();}
 
	llt ret = (int)(ch-'0');
	while( '0' <= (ch=__hv007()) && ch <= '9' ) ret = ret * 10LL + (llt)(ch-'0');
	return sgn ? ret : -ret;
}
 
#ifndef ONLINE_JUDGE
int const SIZE = 13;
#else
int const SIZE = 100+5;
#endif
 

using Real = long double;
using vi = vector<int>;
using pii = pair<int, int>;

llt N;

void proc(){
    if(N & 1) return (void)puts("-1");
    if(N < 4) return (void)puts("-1");

    llt x, y;
    llt left = N % 6;
    if(0 == left) x = N / 6;
    else if(2 == left) x = (N + 4) / 6;
    else if(4 == left) x = (N + 2) / 6;

    left = N % 4;
    if(0 == left) y = N / 4;
    else if(2 == left) y = (N - 2) / 4;

    printf("%lld %lld\n", x, y);
}
 
int main(){
#ifndef ONLINE_JUDGE
    freopen("1.txt", "r", stdin);
#endif
    int nofkase = getInt();
    while(nofkase--){
		N = getInt();
        proc();
    }
    return 0;
}